home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000…tember: Reference Library / Dev.CD Sep 00 RL Disk 1.toast / mac / Technical Documentation / Develop / develop Issue 28 / develop Issue 28 code / MacApp Debugging / TwistDownLists / UProgressIndicators.cp < prev    next >
Encoding:
Text File  |  1996-09-23  |  22.9 KB  |  689 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UProgressIndicators.cp
  3. // ETO20 MacApp 3.3.1, MPW 3.4.1
  4. // Copyright ©1994-1996 Conrad Kopala
  5. // Twist Down Lists version 2.0a0 7/15/96
  6. //----------------------------------------------------------------------------------------
  7.  
  8. #ifndef __UPROGRESSINDICATORS__
  9. #include "UProgressIndicators.h"
  10. #endif
  11.  
  12. #ifndef __UTWISTDOWNGLOBALS__
  13. #include "UTwistDownGlobals.h"
  14. #endif
  15.  
  16. //MacApp stuff
  17. #ifndef __UERRORMGR__
  18. #include "UErrorMgr.h"
  19. #endif
  20.  
  21. //ToolBox stuff
  22. //None
  23.  
  24. //ANSI Stuff
  25. //None
  26.  
  27.  
  28. //----------------------------------------------------------------------------------------
  29. //  Forward and external classes
  30. //----------------------------------------------------------------------------------------
  31. class TProgressBarBehavior;    //forward
  32.  
  33. //========================================================================================
  34. // Global Initialization Procedure
  35. //========================================================================================
  36. #undef Inherited
  37.  
  38. //----------------------------------------------------------------------------------------
  39. // InitUTwistDownView: 
  40. //----------------------------------------------------------------------------------------
  41. #pragma segment DlgInit
  42.  
  43. void InitUProgressDialog()
  44. {
  45.  
  46.     MA_REGISTER_CLASS(TProgressBarIndicator);
  47.     MA_REGISTER_CLASS(TProgressDialogBehavior);
  48.     MA_REGISTER_CLASS(TProgressWindow);
  49.     MA_REGISTER_CLASS(TProgressView);
  50.     MA_REGISTER_CLASS(TProgressBar);
  51.     
  52. }
  53.  
  54. //========================================================================================
  55. // GLOBAL Procedures
  56. //========================================================================================
  57. #undef Inherited
  58.  
  59. //----------------------------------------------------------------------------------------
  60. // NewProgressBarIndicator: 
  61. //----------------------------------------------------------------------------------------
  62. #pragma segment MAFileOpen
  63.  
  64. TProgressBarIndicator* NewProgressBarIndicator(const CStr255& itsOperationString, const CStr255& itsSubjectString)
  65. {
  66.     TProgressBarIndicator * theProgressBarIndicator;
  67.  
  68.     theProgressBarIndicator = new TProgressBarIndicator;
  69.     theProgressBarIndicator -> IProgressBarIndicator(itsOperationString, itsSubjectString);
  70.     return theProgressBarIndicator;
  71. }
  72. //========================================================================================
  73. // CLASS TProgressBarIndicator
  74. //========================================================================================
  75. #undef Inherited
  76. #define Inherited TObject
  77.  
  78. #pragma segment ProgBarOpen
  79. MA_DEFINE_CLASS_M1(TProgressBarIndicator, Inherited);
  80.  
  81. //----------------------------------------------------------------------------------------
  82. // TProgressBarIndicator constructor 
  83. //----------------------------------------------------------------------------------------
  84. #pragma segment ProgBarOpen
  85. TProgressBarIndicator::TProgressBarIndicator()  
  86. {
  87. fMax = 0;
  88. fCurrent = 0;
  89. fStopped = TRUE;
  90. fProgressWindow = NULL;
  91. fProgressView = NULL;
  92. fSubjectString = "";
  93. fUpdateAmount = 1; //set to 1 so as a default the bar appears to be working.
  94.  
  95. #if qDebug
  96. this -> PrintAppConstructorClassInfo();
  97. #endif
  98. }
  99.  
  100. //----------------------------------------------------------------------------------------
  101. // TProgressBarIndicator::~TProgressBarIndicator
  102. //----------------------------------------------------------------------------------------
  103. #pragma segment MADestructorRes
  104.  
  105. TProgressBarIndicator::~TProgressBarIndicator()
  106. {
  107. fProgressWindow = (TWindow*)FreeIfObject(fProgressWindow);
  108. fProgressView = NULL;
  109.  
  110. #if qDebug
  111. this -> PrintAppDestructorClassInfo();
  112. #endif
  113.  
  114. }
  115.  
  116. //----------------------------------------------------------------------------------------
  117. // TProgressBarIndicator::IProgressBarIndicator
  118. //----------------------------------------------------------------------------------------
  119. #pragma segment ProgBarOpen
  120. void TProgressBarIndicator::IProgressBarIndicator(const CStr255& operationString, const CStr255& subjectName)
  121. {
  122. this -> IObject();
  123. fOperationString = operationString;
  124. fSubjectString = subjectName;
  125. }
  126.  
  127. //----------------------------------------------------------------------------------------
  128. // TProgressBarIndicator::CreateProgressView
  129. //----------------------------------------------------------------------------------------
  130. #pragma segment ProgBarOpen
  131. void TProgressBarIndicator::CreateProgressWindow()
  132. {
  133. MAVolatileInit(TWindow*, aProgressWindow, NULL);
  134. MAVolatileInit(TProgressView*, aProgressView, NULL);
  135. MAVolatileInit(TStaticText*, theStaticText, NULL);
  136. MAVolatileInit(TProgressDialogBehavior*, aProgressDialogBehavior, NULL);
  137.  
  138.     if (fProgressWindow == NULL)
  139.         {
  140.             
  141.         if (qTemplateViews)
  142.             {
  143.                                  
  144.                 FailNIL(aProgressWindow = gViewServer -> NewTemplateWindow(kProgressWindowID, NULL));
  145.                 fProgressWindow = aProgressWindow;                        
  146.                 aProgressDialogBehavior = new TProgressDialogBehavior;
  147.                 aProgressDialogBehavior -> IProgressDialogBehavior(TRUE,'stop','    ');                
  148.                 aProgressWindow -> AddBehavior(aProgressDialogBehavior);
  149.                 aProgressView = (TProgressView*) (aProgressWindow -> FindSubView(kProgressViewID));
  150.                 fProgressView = aProgressView;
  151.             }
  152.             
  153.         theStaticText = (TStaticText*) (aProgressWindow -> FindSubView(kProgressOperationViewID));        
  154.         theStaticText -> SetText(fOperationString, kRedraw);
  155.         
  156.         theStaticText = (TStaticText*) (aProgressWindow -> FindSubView(kProgressSubjectViewID));        
  157.         theStaticText -> SetText(fSubjectString, kRedraw);
  158.         theStaticText -> fHelpID = kProgressDialogHelp;
  159.         theStaticText -> fHelpIndex = 1;
  160.         fProgressView -> PrepareToStart(TRUE);
  161.         
  162.         }
  163. }
  164. //----------------------------------------------------------------------------------------
  165. // TProgressBarIndicator::Continue
  166. //----------------------------------------------------------------------------------------
  167. #pragma segment ProgBarRes
  168. void TProgressBarIndicator::Continue()
  169. {
  170.     if (this -> WasCancelled())
  171.         {
  172.             this -> Stop();
  173.         }
  174.     else if (!this -> IsStopped())
  175.         {
  176.             fCurrent = fCurrent + fUpdateAmount;
  177.             this -> DoContinue(fUpdateAmount);
  178.         }
  179.  
  180. }
  181. //----------------------------------------------------------------------------------------
  182. // TProgressBarIndicator::DoUpdate
  183. //----------------------------------------------------------------------------------------
  184. #pragma segment ProgBarRes
  185. void TProgressBarIndicator::DoUpdate(ChangeID theChange, 
  186.                                 TObject* changedObject, TObject* changedBy,TDependencySpace* dependencySpace)
  187. {
  188.     if (theChange == mUpdateProgressBar)
  189.         this -> Continue();
  190.     else
  191.         Inherited::DoUpdate(theChange, changedObject, changedBy, dependencySpace);
  192. }
  193. //----------------------------------------------------------------------------------------
  194. // TProgressBarIndicator::PrepareToStart
  195. //----------------------------------------------------------------------------------------
  196. #pragma segment ProgBarOpen
  197. void TProgressBarIndicator::PrepareToStart(Boolean redraw)
  198. {
  199. MAVolatileInit(Boolean, hasWindow, TRUE);
  200.     
  201. if (fProgressWindow == NULL)
  202.     hasWindow = FALSE;
  203.     
  204. if (hasWindow == FALSE)
  205.     this -> CreateProgressWindow();
  206.     
  207. FlushEvents(everyEvent, 0);
  208. this -> DrawAtOnce(redraw);
  209.  
  210. }
  211. //----------------------------------------------------------------------------------------
  212. // TProgressBarIndicator::Reset
  213. //----------------------------------------------------------------------------------------
  214. #pragma segment ProgBarRes
  215. void TProgressBarIndicator::Reset()
  216. {
  217. fMax = 0;
  218. fCurrent = 0;
  219. }
  220. //----------------------------------------------------------------------------------------
  221. // TProgressBarIndicator::Start
  222. //----------------------------------------------------------------------------------------
  223. #pragma segment ProgBarRes
  224. void TProgressBarIndicator::Start(long max)
  225. {
  226. fMax = max;
  227. fCurrent = 0;
  228. fStopped = FALSE;
  229. fProgressView -> Start(max);
  230. fStopped = FALSE;
  231. }
  232. //----------------------------------------------------------------------------------------
  233. // TProgressBarIndicator::Stop
  234. //----------------------------------------------------------------------------------------
  235. #pragma segment ProgBarRes
  236. void TProgressBarIndicator::Stop()
  237. {
  238. fStopped = TRUE;
  239. fProgressWindow -> Close();
  240. }
  241. //----------------------------------------------------------------------------------------
  242. // TProgressBarIndicator::IsStopped
  243. //----------------------------------------------------------------------------------------
  244. #pragma segment ProgBarRes
  245. Boolean TProgressBarIndicator::IsStopped()
  246. {
  247. return fStopped;
  248. }
  249. //----------------------------------------------------------------------------------------
  250. // TProgressBarIndicator::DoContinue
  251. //----------------------------------------------------------------------------------------
  252. #pragma segment ProgBarRes
  253. void TProgressBarIndicator::DoContinue(long howMuch)
  254. {
  255. fProgressView -> Continue(howMuch);
  256. }
  257. //----------------------------------------------------------------------------------------
  258. // TProgressBarIndicator::DrawAtOnce
  259. //----------------------------------------------------------------------------------------
  260. #pragma segment ProgBarRes
  261. void TProgressBarIndicator::DrawAtOnce(Boolean wholeThing)
  262. {
  263. if (fProgressWindow == NULL)
  264.     this -> PrepareToStart(kRedraw);
  265. else
  266.     {
  267.         if (!fProgressWindow -> IsShown())
  268.             {
  269.                 fProgressWindow -> Select();
  270.                 fProgressWindow -> Open();
  271.             }
  272.             
  273.         if (wholeThing)
  274.             fProgressWindow -> ForceRedraw();
  275.             
  276.         if (fProgressWindow -> Focus())
  277.             fProgressWindow -> Update();
  278.     }    //end else
  279.  
  280. }
  281. //----------------------------------------------------------------------------------------
  282. // TProgressBarIndicator::WasCancelled
  283. //----------------------------------------------------------------------------------------
  284. #pragma segment ProgBarRes
  285. Boolean TProgressBarIndicator::WasCancelled()
  286. {
  287.     MAVolatileInit(Boolean, result, FALSE);
  288.     MAVolatileInit(TProgressDialogBehavior*, itsProgressDialogBehavior, NULL);
  289.     
  290.     itsProgressDialogBehavior = (TProgressDialogBehavior*)(fProgressWindow -> GetBehaviorWithIdentifier(kDialogBehavior));
  291.     
  292.     if (itsProgressDialogBehavior)
  293.     {        
  294.         FailInfo fi;
  295.         Try(fi)
  296.         {
  297.             result = itsProgressDialogBehavior -> WasCancelled();
  298.             fi.Success();
  299.         }
  300.         else // Recover
  301.         {
  302.             fProgressWindow -> CloseAndFree();    
  303.             fi.ReSignal();
  304.         }
  305.     }
  306.     else
  307.     {
  308.         fProgressWindow -> CloseAndFree();
  309. #if qDebug
  310.         ProgramBreak("Can’t test WasCancelled because the window doesn’t contain a TProgressDialogBehavior.");
  311. #endif
  312.  
  313.         gErrorParm3 = "TProgressDialogBehavior";        // show name of class 
  314.         Failure(errMissingClass, 0);
  315.     }
  316.  
  317.     return result;
  318.  
  319. }
  320. //----------------------------------------------------------------------------------------
  321. // TProgressBarIndicator::GetBarLength
  322. //----------------------------------------------------------------------------------------
  323. #pragma segment ProgBarRes
  324. long TProgressBarIndicator::GetBarLength()
  325. {
  326. return fProgressView -> GetBarLength();
  327. }
  328. //----------------------------------------------------------------------------------------
  329. // TProgressBarIndicator::SetUpdateAmountTo
  330. //----------------------------------------------------------------------------------------
  331. #pragma segment ProgBarRes
  332. void TProgressBarIndicator::SetUpdateAmountTo(long updateAmount)
  333. {
  334. fUpdateAmount = updateAmount;
  335. }
  336. //========================================================================================
  337. // CLASS TProgressDialogBehavior
  338. //========================================================================================
  339. #undef Inherited
  340. #define Inherited TDialogBehavior
  341.  
  342. #pragma segment ProgBarOpen
  343. MA_DEFINE_CLASS_M1(TProgressDialogBehavior, Inherited);
  344.  
  345. //----------------------------------------------------------------------------------------
  346. // TProgressDialogBehavior constructor 
  347. //----------------------------------------------------------------------------------------
  348. #pragma segment ProgBarOpen
  349. TProgressDialogBehavior::TProgressDialogBehavior()  
  350. {
  351. #if qDebug
  352. this -> PrintAppConstructorClassInfo();
  353. #endif
  354. }
  355. //----------------------------------------------------------------------------------------
  356. // TProgressDialogBehavior::~TProgressDialogBehavior
  357. //----------------------------------------------------------------------------------------
  358. #pragma segment MADestructorRes
  359. TProgressDialogBehavior::~TProgressDialogBehavior()
  360. {
  361. #if qDebug
  362. this -> PrintAppDestructorClassInfo();
  363. #endif
  364. }
  365. //----------------------------------------------------------------------------------------
  366. // TProgressDialogBehavior::IProgressDialogBehavior
  367. //----------------------------------------------------------------------------------------
  368. #pragma segment ProgBarOpen
  369. void TProgressDialogBehavior::IProgressDialogBehavior(Boolean isModal,IDType  itsDefaultItem,IDType  itsCancelItem)
  370. {
  371.     this -> IDialogBehavior(isModal,itsDefaultItem,itsCancelItem);
  372.  
  373. }
  374. //----------------------------------------------------------------------------------------
  375. // TProgressDialogBehavior::WasCancelled
  376. //----------------------------------------------------------------------------------------
  377. #pragma segment ProgBarRes
  378. Boolean TProgressDialogBehavior::WasCancelled()
  379. {
  380. fDismissed = FALSE;
  381. fDismisser = kNoIdentifier;
  382. MAVolatile(short, oldEventMask);
  383. oldEventMask = gApplication->GetMainEventMask();
  384. gApplication -> SetMainEventMask(oldEventMask & ~highLevelEventMask);
  385.  
  386.     FailInfo fi;
  387.     Try(fi)
  388.     {
  389.     //Note: I've never forced a failure here to see what happens. 
  390.         if (!fDismissed)
  391.             gApplication->PollEvent(kAllowApplicationToSleep);
  392.  
  393.         gApplication->SetMainEventMask(oldEventMask);
  394.         fi.Success();
  395.     }
  396.     else
  397.     {
  398.         gApplication->SetMainEventMask(oldEventMask);
  399.         fi.ReSignal();
  400.     }
  401.  
  402. return fDismissed;
  403. }
  404. //========================================================================================
  405. // CLASS TProgressWindow
  406. //========================================================================================
  407. #undef Inherited
  408. #define Inherited TWindow
  409.  
  410. #pragma segment ProgBarOpen
  411. MA_DEFINE_CLASS_M1(TProgressWindow, Inherited);
  412.  
  413. //----------------------------------------------------------------------------------------
  414. // TProgressWindow constructor 
  415. //----------------------------------------------------------------------------------------
  416. #pragma segment ProgBarOpen
  417. TProgressWindow::TProgressWindow()
  418. {
  419. #if qDebug
  420. this -> PrintAppConstructorClassInfo();
  421. #endif
  422. }
  423. //----------------------------------------------------------------------------------------
  424. // TProgressWindow::~TProgressWindow
  425. //----------------------------------------------------------------------------------------
  426. #pragma segment MADestructorRes
  427. TProgressWindow::~TProgressWindow()
  428. {
  429. #if qDebug
  430. this -> PrintAppDestructorClassInfo();
  431. #endif
  432. }
  433. //----------------------------------------------------------------------------------------
  434. // TProgressWindow::IProgressWindow
  435. //----------------------------------------------------------------------------------------
  436. #pragma segment ProgBarOpen
  437. void TProgressWindow::IProgressWindow(TDocument* itsDocument,WindowPtr itsWMgrWindow,
  438.                                           Boolean canResize,Boolean canClose,Boolean disposeOnFree)
  439. {
  440. this -> IProgressWindow(itsDocument,itsWMgrWindow,canResize,canClose,disposeOnFree);
  441. }
  442. //========================================================================================
  443. // CLASS TProgressView
  444. //========================================================================================
  445. #undef Inherited
  446. #define Inherited TView
  447.  
  448. #pragma segment ProgBarOpen
  449. MA_DEFINE_CLASS_M1(TProgressView, Inherited);
  450.  
  451. //----------------------------------------------------------------------------------------
  452. // TProgressView constructor 
  453. //----------------------------------------------------------------------------------------
  454. #pragma segment ProgBarOpen
  455. TProgressView::TProgressView()  
  456. {
  457. fProgressBar = NULL;
  458. fStopButton = NULL;
  459.  
  460. #if qDebug
  461. this -> PrintAppConstructorClassInfo();
  462. #endif
  463.  
  464. }
  465. //----------------------------------------------------------------------------------------
  466. //  TProgressView::~ TProgressView
  467. //----------------------------------------------------------------------------------------
  468. #pragma segment MADestructorRes
  469. TProgressView::~TProgressView()
  470. {
  471. fProgressBar = NULL;
  472. fStopButton = NULL;
  473.  
  474. #if qDebug
  475. this -> PrintAppDestructorClassInfo();
  476. #endif
  477.  
  478. }
  479. //----------------------------------------------------------------------------------------
  480. // TProgressView::IProgressView
  481. //----------------------------------------------------------------------------------------
  482. #pragma segment ProgBarOpen
  483. void TProgressView::IProgressView(TDocument* itsDocument,TView* itsSuperView,
  484.                                                           const VPoint& itsLocation,const VPoint& itsSize,
  485.                                                           SizeDeterminer itsHSizeDet,SizeDeterminer itsVSizeDet)  
  486. {
  487. this -> IView(itsDocument,itsSuperView,itsLocation,itsSize,itsHSizeDet,itsVSizeDet);
  488. }
  489. //----------------------------------------------------------------------------------------
  490. // TProgressView::Continue
  491. //----------------------------------------------------------------------------------------
  492. #pragma segment ProgBarRes
  493. void TProgressView::Continue(long howMuch)
  494. {
  495. fProgressBar -> Continue(howMuch);
  496. }
  497. //----------------------------------------------------------------------------------------
  498. // TProgressView::DrawAtOnce
  499. //----------------------------------------------------------------------------------------
  500. #pragma segment ProgBarRes
  501. void TProgressView::DrawAtOnce(Boolean redraw)
  502. {
  503. #pragma unused redraw
  504. }
  505. //----------------------------------------------------------------------------------------
  506. // TProgressView::PrepareToStart
  507. //----------------------------------------------------------------------------------------
  508. #pragma segment ProgBarRes
  509. void TProgressView::PrepareToStart(Boolean redraw)
  510. {
  511. #pragma unused redraw
  512. fProgressBar = (TProgressBar*) (this -> FindSubView(kProgressBarViewID));
  513. fProgressBar -> SetBarSize();
  514. fProgressBar -> SetPen();
  515. fProgressBar ->fHelpID = kProgressDialogHelp;
  516. fProgressBar ->fHelpIndex = 2;
  517. }
  518. //----------------------------------------------------------------------------------------
  519. // TProgressView::Reset
  520. //----------------------------------------------------------------------------------------
  521. #pragma segment ProgBarRes
  522. void TProgressView::Reset()
  523. {
  524. fProgressBar -> Reset();
  525. }
  526. //----------------------------------------------------------------------------------------
  527. // TProgressView::Start
  528. //----------------------------------------------------------------------------------------
  529. #pragma segment ProgBarRes
  530. void TProgressView::Start(long max)
  531. {
  532. fProgressBar -> Start(max);
  533. }
  534. //----------------------------------------------------------------------------------------
  535. // TProgressView::Stop
  536. //----------------------------------------------------------------------------------------
  537. #pragma segment ProgBarRes
  538. void TProgressView::Stop()
  539. {
  540.  
  541. }
  542. //----------------------------------------------------------------------------------------
  543. // TProgressView::GetBarLength
  544. //----------------------------------------------------------------------------------------
  545. #pragma segment ProgBarRes
  546. long TProgressView::GetBarLength()
  547. {
  548. return fProgressBar -> GetBarLength();
  549. }
  550. //========================================================================================
  551. // CLASS TProgressBar
  552. //========================================================================================
  553. #undef Inherited
  554. #define Inherited TControl
  555.  
  556. #pragma segment AOpen
  557. MA_DEFINE_CLASS_M1(TProgressBar, Inherited);
  558.  
  559. //----------------------------------------------------------------------------------------
  560. // TProgressBar constructor 
  561. //----------------------------------------------------------------------------------------
  562. #pragma segment ProgBarOpen
  563. TProgressBar::TProgressBar()  
  564. {
  565. fMax = 0;
  566. fCurrent = 0;
  567. fBarRect = gZeroVRect;
  568.  
  569. #if qDebug
  570. this -> PrintAppConstructorClassInfo();
  571. #endif
  572.  
  573. }
  574. //----------------------------------------------------------------------------------------
  575. // TProgressBar::~TProgressBar
  576. //----------------------------------------------------------------------------------------
  577. #pragma segment MADestructorRes
  578.  
  579. TProgressBar::~TProgressBar()
  580. {
  581. #if qDebug
  582. this -> PrintAppDestructorClassInfo();
  583. #endif
  584. }
  585. //----------------------------------------------------------------------------------------
  586. // TProgressBar::IProgressBar
  587. //----------------------------------------------------------------------------------------
  588. #pragma segment ProgBarOpen
  589. void TProgressBar::IProgressBar(TView* itsSuperView,const VPoint& itsLocation,const VPoint& itsSize,
  590.                                         SizeDeterminer itsHSizeDet,SizeDeterminer itsVSizeDet,const TextStyle& itsTextStyle)  
  591. {
  592. this -> IControl(itsSuperView,itsLocation,itsSize,itsHSizeDet,itsVSizeDet,itsTextStyle);
  593. }
  594. //----------------------------------------------------------------------------------------
  595. // TProgressBar::SetBarSize
  596. //----------------------------------------------------------------------------------------
  597. #pragma segment ProgBarOpen
  598. void TProgressBar::SetBarSize()
  599. {
  600. fBarRect.right = fSize.h;
  601. fBarRect.bottom = fSize.v;
  602. }
  603. //----------------------------------------------------------------------------------------
  604. // TProgressBar::SetPen
  605. //----------------------------------------------------------------------------------------
  606. #pragma segment ProgBarOpen
  607. void TProgressBar::SetPen()
  608. {
  609. GetPenState(&fPen);
  610. }
  611. //----------------------------------------------------------------------------------------
  612. // TProgressBar::Draw
  613. //----------------------------------------------------------------------------------------
  614. #pragma segment ProgBarRes
  615. void TProgressBar::Draw(const VRect& area)
  616. {
  617. #pragma unused area
  618. PenState oldPen;
  619. PenState newPen;
  620. VRect barRect;
  621. long barLength;
  622. VRect controlArea;
  623. CRect qdArea;
  624.  
  625. if (fCurrent > 0)
  626.     {
  627.         
  628.         GetPenState(&oldPen);
  629.         newPen = fPen;
  630.         SetPenState(&newPen);
  631.         barRect = fBarRect;
  632.         barLength = barRect.right - barRect.left;
  633.         barRect.right = ((barLength*fCurrent)/fMax);
  634.         
  635.         if (barRect.right > fBarRect.right)
  636.             barRect.right = fBarRect.right;
  637.         
  638.         this -> ViewToQDRect(barRect, qdArea);
  639.         PaintRect(qdArea);
  640.         
  641.         SetPenState(&oldPen);
  642.     }
  643. }
  644. //----------------------------------------------------------------------------------------
  645. // TProgressBar::Continue
  646. //----------------------------------------------------------------------------------------
  647. #pragma segment ProgBarRes
  648. void TProgressBar::Continue(long howMuch)
  649. {
  650. fCurrent = fCurrent + howMuch;
  651. VRect area;
  652.  
  653. this -> DrawContents();    
  654. }
  655. //----------------------------------------------------------------------------------------
  656. // TProgressBar::Reset
  657. //----------------------------------------------------------------------------------------
  658. #pragma segment ProgBarRes
  659. void TProgressBar::Reset()
  660. {
  661. fCurrent = 0;
  662. this -> Update();
  663. }
  664. //----------------------------------------------------------------------------------------
  665. // TProgressBar::Start
  666. //----------------------------------------------------------------------------------------
  667. #pragma segment ProgBarRes
  668. void TProgressBar::Start(long max)
  669. {
  670. fMax = max;
  671. }
  672. //----------------------------------------------------------------------------------------
  673. // TProgressBar::Stop
  674. //----------------------------------------------------------------------------------------
  675. #pragma segment ProgBarRes
  676. void TProgressBar::Stop()
  677. {
  678.  
  679. }
  680. //----------------------------------------------------------------------------------------
  681. // TProgressBar::GetBarLength
  682. //----------------------------------------------------------------------------------------
  683. #pragma segment ProgBarRes
  684. long TProgressBar::GetBarLength()
  685. {
  686. return fSize.h;
  687. }
  688.  
  689. #pragma segment Inline